package com.wsb.service.impl;


import com.wsb.dao.SmbmsUserDao;
import com.wsb.entry.SmbmsUser;
import com.wsb.service.LoginService;
import com.wsb.utils.MybatisUtils;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.io.InputStream;
@Service("loginService")
public class LoginServiceImpl  implements LoginService {
    @Autowired
    SmbmsUserDao smbmsUserDao;
    @Override
    public boolean login(String userCode,String userPassword){
        System.out.println(userCode);
        System.out.println(userPassword);
        //service 业务层 职责：调用dao层
//        SmbmsUserDao smbmsUserDao=new SmbmsUserDaoImpl();
//        SmbmsUser smbmsUser = smbmsUserDao.getSmbmsUserCode(userCode);

        //SqlSession sqlSession = MybatisUtils.getSqlSession();
        //SmbmsUserDao smbmsUserDao =sqlSession.getMapper(SmbmsUserDao.class);
        SmbmsUser smbmsUser =smbmsUserDao.getSmbmsUserCode(userCode);
        if(smbmsUser!=null){
            if(userPassword.equals(smbmsUser.getUserPassword())){
                return true;
            }else{
                return false;
            }
        }else{
            return false;
        }

    }
}
